#!/usr/bin  python
# _*_ coding:utf-8 _*_
"""
----------------------------------
    File Name: parent
    Description:
        Author: Dell
        Date: 2020/8/6
-----------------------------------
"""

from rest_framework import serializers
from Baby import models


class ParentModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Users
        fields = (
            "id", "first_name", "last_name", "group", "hospital", "full_name", "relationship", "study_id_number",
            "email", "stop_service"
        )
        extra_kwargs = {
            "id": {
                "read_only": True
            }
        }

    def validate(self, attrs):
        attrs["full_name"] = "{} {}".format(attrs["first_name"], attrs["last_name"])
        return attrs
